package exceptionHomework;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo_2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos=new FileOutputStream("test2.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw);
        Scanner scanner=new Scanner(System.in);

        System.out.println("请输入内容，单独输入exit退出");
        while(true){
            String line=scanner.nextLine();
            if("exit".equals(line)){
                break;
            }
            pw.println(line);
        }
        System.out.println("输入完毕！");
        pw.close();
    }
}
